using System.Collections.Generic;

using octalforty.Componento.ComponentModel.Commanding;
using octalforty.Componento.ComponentModel.Packaging;
using octalforty.Componento.Core;

namespace octalforty.Componento
{
    class Program
    {
        static void Main(string[] args)
        {
            IServiceProvider serviceProvider = new ServiceProvider();
            serviceProvider.RegisterService<IPackageRepositoryBrowserProviderService>(
                delegate(IServiceProvider sp)
                    { return new PackageRepositoryBrowserProviderService(sp); });

            switch(args[0].ToLowerInvariant())
            {
                case "list":
                    new ListCommand().Execute(serviceProvider, GetArgs(args));
                    return;
                case "install":
                    new InstallCommand().Execute(serviceProvider, GetArgs(args));
                    return;
            }
        }

        private static CommandArgumentContainer GetArgs(string[] args)
        {
            List<string> _args = new List<string>(args);
            _args.RemoveAt(0);

            return new CommandArgumentContainer(_args.ToArray());
        }
    }
}
